#include "aaScreen.h" 

int AA_Screen::init () {
   context = aa_autoinit (&aa_defparams);
   if (context == NULL)
   {
      std::cerr << "Failed to initialize aalib\n";
      return (1);
   }
   //This is the size in chars
   aaScrWidth = aa_scrwidth ( context );
   aaScrHeight = aa_scrheight ( context );

   //This is the size in pixels
   sysWidth = aa_imgwidth ( context );
   sysHeight = aa_imgheight ( context );

   framebuffer = aa_image ( context );

   aa_putpixel ( context, 10, 10, 100 );

   return 0;
}

void AA_Screen::done () {
   aa_close ( context );
}

void AA_Screen::draw( int x, int y, char c) {
   aa_putpixel ( context, x, y, 100 );
}

void AA_Screen::render() { 
   aa_render (context, &aa_defrenderparams,
      0, 0, aa_scrwidth (context), aa_scrheight (context));
}

int AA_Screen::flush () {
   aa_flush (context); //aa_flush is void
   return 0;
}
